package org.example.controller;

import org.example.dto.UserDTO;
import org.example.service.GrpcClientServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author wangjun
 * @Date 2025/3/17 10:41
 */
@RestController
public class GrpcDemoController {

    @Autowired
    private GrpcClientServiceImpl grpcClientService;

    @GetMapping
    public String getString() {
        return "success";
    }

//    @PostMapping("/test/sync")
//    public Object syncGrpc(@RequestBody UserDTO user) {
//        return grpcClientService.syncRegisterInstance(user);
//    }

    @PostMapping("/test/async")
    public Object asyncGrpc(@RequestBody UserDTO user) {
//        return grpcClientService.asyncRegisterInstance(user);
        return null;
    }

    @PostMapping("/test/async/two")
    public Object asyncGrpcTwo(@RequestBody UserDTO user) {
        return grpcClientService.testBidirectionalService();
    }

//    @PostMapping("/test/async/error")
//    public Object asyncGrpcError(@RequestBody UserDTO user) {
//        return grpcClientService.asyncErrorRegisterInstance(user);
//    }
//
//    @PostMapping("/test/listener")
//    public Object listenerGrpc(@RequestBody UserDTO user) {
//        return grpcClientService.listenerRegisterInstance(user);
//    }
}
